import type { PropType } from 'vue';
import { propTypes } from '@/utils/propTypes';
import type { PaginationProps } from './types/pagination';
import type { SizeType, BasicColumn, TableSetting } from './types/table';
import type { TableDraggable } from '@arco-design/web-vue/es/table';
import { ScrollbarProps } from '@arco-design/web-vue/es/scrollbar';

export const basicProps = {
  //原组件参数
  columns: {
    type: [Array] as PropType<BasicColumn[]>,
    default: () => [],
  },
  dataSource: {
    type: Array as PropType<Recordable[]>,
    default: undefined,
  },
  bordered: {
    type: Boolean,
    default: true,
  },
  hoverable: {
    type: Boolean,
    default: true,
  },
  stripe: {
    type: Boolean,
    default: false,
  },
  size: {
    type: String as PropType<SizeType>,
    default: 'middle',
  },
  tableLayoutFixed: {
    type: Boolean,
    default: false,
  },
  loading: {
    type: Boolean,
    default: false,
  },
  hideHeader: {
    type: Boolean,
    default: false,
  },
  rowSelection: propTypes.object,
  expandable: propTypes.object,
  scroll: propTypes.object,
  pagination: {
    type: [Object, Boolean] as PropType<PaginationProps | boolean>,
    default: undefined,
  },
  pagePosition: {
    type: String,
    default: 'br',
  },
  indentSize: {
    type: Number,
    default: 16,
  },
  rowKey: {
    type: String,
    default: 'key',
  },
  showHeader: {
    type: Boolean,
    default: true,
  },
  virtualListProps: propTypes.object,
  spanMethod: {
    type: Function,
  },
  spanAll: {
    type: Boolean,
    default: false,
  },
  loadMore: {
    type: Function,
  },
  filterIconAlignLeft: {
    type: Boolean,
    default: false,
  },
  hideExpandButtonOnEmpty: {
    type: Boolean,
    default: false,
  },
  rowClass: {
    type: [String, Function],
  },
  draggable: {
    type: Object as PropType<TableDraggable>,
  },
  columnResizable: {
    type: Boolean,
    default: false,
  },
  summary: {
    type: [Boolean, Function],
  },
  summaryText: {
    type: String,
    default: 'Summary',
  },
  summarySpanMethod: {
    type: Function,
  },
  selectedKeys: {
    type: Array as PropType<String[] | Number[]>,
  },
  defaultSelectedKeys: {
    type: Array as PropType<String[] | Number[]>,
  },
  expandedKeys: {
    type: Array as PropType<String[] | Number[]>,
  },
  defaultExpandedKeys: {
    type: Array as PropType<String[] | Number[]>,
  },
  defaultExpandAllRows: {
    type: Boolean,
    default: false,
  },
  stickyHeader: {
    type: [Boolean, Number],
    default: false,
  },
  scrollbar: {
    type: [Boolean, Object] as PropType<Boolean | ScrollbarProps>,
    default: true,
  },
  //end

  //自定义参数
  leftTitle: {
    type: String,
    default: undefined,
  },
  leftTitleTooltip: {
    type: String,
    default: undefined,
  },
  request: {
    type: Function as PropType<(...arg: any[]) => Promise<any>>,
    default: undefined,
  },
  //废弃
  showPagination: {
    type: [String, Boolean],
    default: 'auto',
  },
  actionColumn: {
    type: Object,
    default: undefined,
  },
  // 表格滚动最大高度
  maxHeight: {
    type: Number as PropType<number>,
    default: 0,
  },
  showTableSetting: {
    type: Boolean,
    default: true,
  },
  tableSetting: {
    type: Object as PropType<TableSetting>,
    default: () => ({
      width: 230,
      redo: true,
      size: true,
      setting: true,
      fullscreen: true,
      striped: true,
    }),
  },
  canResize: propTypes.bool.def(true),
  resizeHeightOffset: propTypes.number.def(0),
  isKeepRowKeys: {
    type: Boolean,
    default: false,
  },
};
